//
//  GS_HeroTopTableViewCell.m
//  GoodManNews
//
//  Created by dllo on 16/1/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "GS_HeroTopTableViewCell.h"

@implementation GS_HeroTopTableViewCell

- (void)dealloc
{
    [_firstColorL release];
    [_secondColorL release];
    [_firstL release];
    [_secondL release];
    [_firstPersentL release];
    [_secondPersentL release];
    [_numL release];
    [_imageV release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    NSLog(@"%ld", self.type);
    [self.numL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.top.bottom.mas_equalTo(self.contentView);
        make.right.mas_equalTo(self.imageV.mas_left);
        make.width.mas_equalTo(@40);
        
    }];
    
    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentView).with.offset(10);
        make.bottom.equalTo(self.contentView).with.offset(-10);
        make.width.mas_equalTo(@80);
        
    }];
    
    [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.imageV.mas_right).with.offset(10);
        make.top.equalTo(self.contentView).with.offset(13);
        make.bottom.equalTo(self.firstL.mas_top).with.offset(-5);
        make.height.mas_equalTo(@25);
        make.width.mas_equalTo(@200);
        
    }];
    
    [self.firstL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.imageV.mas_right).with.offset(10);
//        make.top.equalTo(self.nameL.mas_bottom).with.offset(5);
        make.bottom.equalTo(self.secondL.mas_top).with.offset(-5);
        make.width.equalTo(@50);
        make.height.equalTo(self.secondL);
        
    }];

    [self.secondL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.firstL.mas_bottom).with.offset(5);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
        make.left.equalTo(self.imageV.mas_right).with.offset(10);
        make.height.equalTo(self.firstL);
        make.width.equalTo(@50);
        
    }];
    
    if (1 == self.type) {
        
        [self.firstColorL mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.firstL.mas_right).with.offset(10);
            make.top.equalTo(self.nameL.mas_bottom).with.offset(5);
            make.height.equalTo(self.firstL);
            make.width.equalTo(@(15 * self.deb));
            
        }];
        
        [self.secondColorL mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.firstL.mas_right).with.offset(10);
            make.top.equalTo(self.firstColorL.mas_bottom).with.offset(5);
            make.height.equalTo(self.secondL);
            make.width.equalTo(@(2 * self.win));
            
        }];
    } else if (2 == self.type) {
        
        [self.firstColorL mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.firstL.mas_right).with.offset(10);
            make.top.equalTo(self.nameL.mas_bottom).with.offset(5);
            make.height.equalTo(self.firstL);
            make.width.equalTo(@(15 * self.deb));
            
        }];
        
        [self.secondColorL mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.firstL.mas_right).with.offset(10);
            make.top.equalTo(self.firstColorL.mas_bottom).with.offset(5);
            make.height.equalTo(self.secondL);
            make.width.equalTo(@(1.5 * self.win));
            
        }];

        
    } else if (3 == self.type) {
        
        [self.firstColorL mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.firstL.mas_right).with.offset(10);
            make.top.equalTo(self.nameL.mas_bottom).with.offset(5);
            make.height.equalTo(self.firstL);
            make.width.equalTo(@(10 * self.deb));
            
        }];
        
    }
    
    [self.firstPersentL mas_updateConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.firstColorL.mas_right).with.offset(10);
        make.top.equalTo(self.firstColorL);
        make.height.equalTo(self.firstL);
        make.width.equalTo(@50);
        
    }];
    
    [self.secondPersentL mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.secondColorL.mas_right).with.offset(10);
        make.top.equalTo(self.secondColorL);
        make.height.equalTo(self.secondL);
        make.width.equalTo(@50);
        
    }];
    
    

    
}

- (void)createSubviews
{
    self.numL = [UILabel new];
//    self.numL.backgroundColor = [UIColor yellowColor];
    self.numL.textAlignment = NSTextAlignmentCenter;
    self.numL.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:self.numL];
    
    self.imageV = [UIImageView new];
//    self.imageV.backgroundColor = [UIColor purpleColor];
    [self.contentView addSubview:self.imageV];
    
    self.nameL = [UILabel new];
//    self.nameL.backgroundColor = [UIColor redColor];
    self.nameL.textColor = [UIColor blackColor];
    self.nameL.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.nameL];
    
    self.firstL = [UILabel new];
//    self.firstL.backgroundColor = [UIColor orangeColor];
    self.firstL.font = [UIFont systemFontOfSize:13];
    self.firstL.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.firstL];
    
    self.secondL = [UILabel new];
//    self.secondL.backgroundColor = [UIColor orangeColor];
    self.secondL.font = [UIFont systemFontOfSize:13];
    self.secondL.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.secondL];
    
    self.firstColorL = [UILabel new];
//    self.firstColorL.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:self.firstColorL];
    
    self.secondColorL = [UILabel new];
//    self.secondColorL.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.secondColorL];
    
    self.firstPersentL = [UILabel new];
//    self.firstPersentL.backgroundColor = [UIColor blackColor];
    self.firstPersentL.font = [UIFont systemFontOfSize:13];
    self.firstPersentL.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.firstPersentL];
    
    self.secondPersentL = [UILabel new];
//    self.secondPersentL.backgroundColor = [UIColor blackColor];
    self.secondPersentL.font = [UIFont systemFontOfSize:13];
    self.secondPersentL.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.secondPersentL];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
